<template>
	<div>
		<p>role_management</p>
		<p>role_management</p>
		<p>role_management</p>
		<p>role_management</p>
		<p>role_management</p>
	</div>
</template>

<script>
import Vue from 'vue'
// 自定义权限鉴定指令
const has = Vue.directive('has',{
 bind:((el,binding,vnode)=>{
   console.log(el);
   // 获取页面按钮权限
    let btnPermissionsArr = [];
    if (binding.value){
      // 指令传值,获取指令参数,根据指令参数和当前登录身份按钮权限对比
      btnPermissionsArr  = Array.of(binding.value);
    } else {
      // 否则 获取路由中的参数,根据路由的 btnPermissionsArr 和当前登录身份按钮权限对比
      /**
       * btnPermissionsmeta: {
       *  btnPermissions: ['admin']
       *  } //页面需要的权限
       */
      btnPermissionsArr = vnode.context.$route.meta.btnPermissions;
    }
    if(!Vue.Prototype.$_has(btnPermissionsArr)){
      el.parentNode.removeChild(el);
    }
 }),
  inserted:(el => {
    console.log(el);
    // 聚焦元素
    el.focus();
  })
})
export default {
	components: {},
	data() {
		return {}
	},
	created() {},

	methods: {},
}
</script>

<style scoped lang='scss'>
</style>
